<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        div{
            width: 200px;
            height: 200px;
        }
        /* 由于box1的margin-bottom和box2的margin-top其实是重合的，而box1的5px是大于box2的2px的，所以根据规则，会取较大的那个，也就是5px，所以box2即使设置的是2px的顶部外边距，视觉上依然会是5px */
        .box1{
            background-color: red;
            margin-bottom: 5px;
        }
        .box2{
            background-color: pink;
            margin-top: 2px;
        }
    </style>
</head>
<body>
    <div class="box1"></div>
    <div class="box2"></div>
</body>
</html>